package cn.yunhe.crm.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.yunhe.crm.dao.DiaryMapper;
import cn.yunhe.crm.entity.Diary;

@Service("DiaryService")
public class DiaryService {
	@Autowired
	private DiaryMapper dMapper;

	public void setdMapper(DiaryMapper dMapper) {
		this.dMapper = dMapper;
	}
	/**
	 * 查询日志总数
	 * @return
	 */
	public int checkCount(){
		return dMapper.countByExample(null);
	}
	/**
	 * 根据时间查询日志总数
	 * @param begintime
	 * @param endtime
	 * @return
	 */
	public int checkCountByYearAndMonth(String begintime,String endtime){
		Map map=new HashMap();
		map.put("begintime", begintime);
		map.put("endtime", endtime);
		return dMapper.checkCountByYearAndMonth(map);
	}
	
	
	//日志管理部分
	/**
	 * 查询所有日志
	 * @return
	 */
	public List<Diary> findAllDiary(){
		List<Diary> diarylist= dMapper.findAllDiary();
		return diarylist;
	}
	/**
	 * 查看日志详情
	 */
	public Diary findDiaryById(Integer id) {
		return dMapper.findDiaryById(id);
	}
	/**
	 * 添加日志
	 */
	public int insertDiary(Diary diary){
		int add=dMapper.insertDiary(diary);
		return add;
	}
	
	   public int countByToday(){
    	   
		     return dMapper.checkCountByToday();
		}
	
}
